import Vue from 'vue'
import Router from 'vue-router'

import authManageRoute from './modules/auth-manage'
import customerRoute from './modules/customer'
import rechargeRoute from './modules/recharge-manage'
import gameManageRoute from './modules/game-manage'

/* Layout */
import Layout from '@/views/layout/Layout'
Vue.use(Router)

export const constantRouterMap = [
  {
    path: '/redirect',
    component: Layout,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    name: 'Login',
    path: '/login',
    component: () => import('@/views/login/index.vue')
  },
  {
    name: 'ChangePassword',
    path: '/change-password',
    component: () => import('@/views/change-password/index.vue')
  },
  {
    path: '',
    redirect: 'dashboard',
    component: Layout,
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard'
      }
    ]
  },
  // 权限路由
  authManageRoute,
  // 游戏用户
  customerRoute,
  // 充值记录
  rechargeRoute,
  // 游戏支持
  gameManageRoute,
  // 错误页
  {
    path: '/errors',
    component: Layout,
    children: [
      {
        name: 'NotFound',
        path: 'not-found',
        component: () => import('@/views/errors/not-found.vue')
      },
      {
        name: 'NoAccess',
        path: 'no-access',
        component: () => import('@/views/errors/no-access.vue')
      }
    ]
  },
  { path: '*', redirect: '/errors/not-found' }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
